-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebase Integration and Confidence Filtering #35
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
==========================================
- Coverage 52.66% 52.12% -0.53%
==========================================
Files 38 38
Lines 1396 1443 +47
==========================================
+ Hits 735 752 +17
- Misses 661 691 +30
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
@@ -80,4 +95,9 @@ class CoughDetectionViewModel { | |||
identifiedSound = nil | |||
coughAnalysisManager.stopCoughDetection() | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this used? If not necessary, please remove.
CoughSync/CoughSyncStandard.swift
Outdated
} | ||
|
||
// For batch saving multiple coughs at once (optional) | ||
func add(coughs: [Cough]) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not used now, please remove.
@@ -13,51 +13,63 @@ | |||
// | |||
|
|||
import SwiftUI | |||
import Spezi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this error
CoughSync/Dashboard/Dashboard.swift
Outdated
@State private var previousCoughCount: Int = 0 | ||
|
||
init(presentingAccount: Binding<Bool>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. Just make sure to fix the errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bugs fixed now
Firebase Integration and Confidence Filtering
♻️ Current situation & Problem
Currently, the CoughSync app can detect coughs using sound analysis, but these detections are not persisted to any backend service. This means that cough data is lost when the app is closed, preventing long-term tracking and analysis. Additionally, the current implementation accepts all detected coughs regardless of confidence level, leading to potential false positives. This PR implements the Firebase integration for cough data storage, fixes dependency injection issues in the CoughDetectionViewModel, and adds confidence filtering to ensure only high-quality cough detections are recorded.
⚙️ Release Notes
Key features:
Cough detections are now automatically stored in Firebase via the CoughSyncStandard
Only moderate-confidence coughs (>50%) are recorded to reduce false positives
Cough model enhanced to include confidence score information
Fixed dependency injection issues in view models to properly access the -
CoughSyncStandard
Example of Firebase integration and confidence filtering:
if displayName == "Coughs" && confidence > 0.5 { // Only record if confidence > 50%
let cough = Cough(timestamp: Date(), confidence: confidence)
coughCollection.addCough(cough)
// Store the cough in Firebase
Task {
await standard.add(cough: cough)
}
}
📚 Documentation
This PR introduces Firebase integration for persistent storage of cough detection data. When a cough is detected with sufficient confidence (>50%), it is both stored locally in the CoughCollection and sent to Firebase through the CoughSyncStandard interface. The Cough model has been enhanced to include a confidence property that stores the machine learning model's confidence level for each detection. This value ranges from 0.0 to 1.0, with higher values indicating greater confidence. By filtering coughs at the 0.5 threshold, we significantly reduce false positives while maintaining detection sensitivity. The dependency injection architecture has been improved to properly access the CoughSyncStandard from the SwiftUI environment. This follows the Spezi framework's recommended patterns for dependency injection, initializing view models when their containing views appear to ensure environment values are available. All code changes are documented with inline comments explaining the purpose of each component and the rationale behind design decisions, in accordance with the Spezi Documentation Guide.
✅ Testing
Testing verified Firebase storage, confidence filtering effectiveness, and dependency injection fixes. Manual testing was used due to audio input simulation challenges.
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: